<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="订单号" prop="roomOrderId">
        <el-input
          v-model="queryParams.roomOrderId"
          placeholder="请输入订单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用户名" prop="userName">
        <el-input
          v-model="queryParams.userName"
          placeholder="请输入用户名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手机号" prop="phone">
        <el-input
          v-model="queryParams.phone"
          placeholder="请输入手机号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索
        </el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          >新增</el-button
        >
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          @click="handleUpdate"
          >修改</el-button
        >
      </el-col> -->
      <!-- <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          >批量删除</el-button
        >
      </el-col> -->
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="dataList"
      @selection-change="handleSelectionChange"
    >
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <el-table-column label="包间订单ID" align="center" prop="roomOrderId" />
      <el-table-column label="区域名称" align="center" prop="areaName" />
      <el-table-column label="门店名称" align="center" prop="shopName" />
      <el-table-column label="用户名" align="center" prop="userName" />
      <el-table-column label="手机号" align="center" prop="phone" />
      <el-table-column label="包间名称" align="center" prop="roomName" />
      <el-table-column label="支付金额" align="center" prop="payMoney" />
      <el-table-column
        prop="orderType"
        label="支付状态"
        filter-placement="bottom-end"
      >
        <template slot-scope="scope">
          <el-tag
            v-if="scope.row.orderType == 1"
            type="warning"
            disable-transitions
            >未支付</el-tag
          >
          <el-tag
            v-if="scope.row.orderType == 2"
            type="success"
            disable-transitions
            >已支付</el-tag
          >
          <el-tag
            v-if="scope.row.orderType == 3"
            type="danger"
            disable-transitions
            >已退款</el-tag
          >
          <el-tag
            v-if="scope.row.orderType == 4"
            type="info"
            disable-transitions
            >退款失败</el-tag
          >
          <el-tag v-if="!scope.row.orderType" type="info" disable-transitions
            >暂无</el-tag
          >
        </template>
      </el-table-column>
      <el-table-column
        label="创建时间"
        align="center"
        width="180"
        prop="createTime"
      />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        fixed="right"
        width="200"
      >
        <template slot-scope="scope">
          <el-button
            v-if="scope.row.orderType == 1"
            size="mini"
            type="text"
            @click="handleUpdata(scope.row)"
            >修改</el-button
          >

          <el-button
            v-if="scope.row.orderType == 2"
            size="mini"
            type="text"
            @click="handleChargeback(scope.row)"
            >退单</el-button
          >

          <el-button
            v-if="scope.row.orderType == 1"
            size="mini"
            type="text"
            @click="handleDelete(scope.row)"
            >删除</el-button
          >

          <el-popover
            placement="right"
            width="400"
            trigger="click"
            v-model="scope.row.visible"
            @hide="(scope.row.visible = false), (formList = {})"
          >
            <el-form
              ref="formListRef"
              :model="formList"
              :rules="rulesList"
              label-width="110px"
            >
              <el-form-item label="支付方式" prop="payType">
                <el-select
                  clearable
                  v-model="scope.row.payType"
                  disabled
                  placeholder="请选择支付方式"
                >
                  <el-option
                    v-for="(item, index) of payTypeList"
                    :key="index"
                    :label="item.label"
                    :value="item.value"
                    >{{ item.label }}</el-option
                  >
                </el-select>
              </el-form-item>
              <el-form-item
                label="条形码"
                prop="payCode"
                v-if="scope.row.payType == 2"
              >
                <el-input
                  autofocus
                  v-model="formList.payCode"
                  placeholder="请输入条形码"
                  @change="handleScanCode1"
                  :ref="scope.row.PayIndex"
                  style="width: 200px"
                ></el-input>
              </el-form-item>
              <el-form-item class="dialog-footer">
                <el-button
                  size="mini"
                  type="primary"
                  @click="handReset(scope.row)"
                  >确 定</el-button
                >
                <el-button
                  size="mini"
                  @click="(scope.row.visible = false), (formList = {})"
                  >取 消</el-button
                >
              </el-form-item>
            </el-form>

            <el-button
              slot="reference"
              size="mini"
              v-if="scope.row.orderType == 1"
              class="ml-10"
              type="text"
              >支付</el-button
            >
          </el-popover>
        </template>
      </el-table-column>
    </el-table>

    <el-dialog
      :title="title"
      :visible.sync="open"
      width="700px"
      append-to-body
      :close-on-click-modal="false"
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="所属区域" prop="areaId">
              <el-select
                clearable
                v-model="form.areaId"
                placeholder="请选择所属区域"
                @change="changeArea"
              >
                <el-option
                  v-for="(item, index) of areaList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                  >{{ item.label }}</el-option
                >
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所属门店" prop="shopId">
              <el-select
                clearable
                v-model="form.shopId"
                placeholder="请选择所属门店"
                @change="changeStore"
              >
                <el-option
                  v-for="(item, index) of storeList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                  >{{ item.label }}</el-option
                >
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="客户手机号" prop="phone">
              <el-input
                v-model="form.phone"
                placeholder="请输入客户手机号"
                style="width: 200px"
              ></el-input>
              <!-- <el-select
                clearable
                v-model="form.phone"
                allow-create
                filterable
                @change="changeUserPhone"
              >
                <el-option
                  v-for="(item, index) of userNamelist"
                  :key="index"
                  :label="item.value"
                  :value="item.key"
                  >{{ item.value }}</el-option
                >
              </el-select> -->
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="客户姓名" prop="userName">
              <el-input
                v-model="form.userName"
                placeholder="请输入客户姓名"
                style="width: 200px"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="包间类型" prop="roomType">
              <el-select
                clearable
                v-model="form.roomType"
                placeholder="请选择包间类型"
                @change="changeRoomType"
              >
                <el-option
                  v-for="(item, index) of roomTypeList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                  >{{ item.label }}</el-option
                >
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订单">
              <el-select
                clearable
                v-model="form.orderId"
                filterable
                remote
                placeholder="请优先选择包间类型"
                :remote-method="orderRemoteMethod"
                :disabled="!form.roomType"
                @change="changeOrder"
              >
                <el-option
                  v-for="(item, index) of orderList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                  >{{ item.label }}</el-option
                >
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="技师" prop="technicianId">
              <el-select
                clearable
                v-model="form.technicianId"
                placeholder="请选择技师"
              >
                <el-option
                  v-for="(item, index) of technicianList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                  >{{ item.label }}</el-option
                >
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="开始时间" prop="startTime">
              <el-date-picker
                :picker-options="pickerOptions"
                v-model="form.startTime"
                value-format="yyyy-MM-dd HH:mm:ss"
                type="datetime"
                placeholder="请选择开始时间"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="结束时间" prop="endTime">
              <el-date-picker
                :picker-options="pickerOptions"
                v-model="form.endTime"
                value-format="yyyy-MM-dd HH:mm:ss"
                type="datetime"
                placeholder="请选择结束时间"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="包间" prop="roomId">
              <el-select
                clearable
                v-model="form.roomId"
                placeholder="请选择包间"
                @change="changeRoom"
              >
                <el-option
                  v-for="(item, index) of roomList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                  >{{ item.label }}</el-option
                >
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="床位数量" prop="bedNum">
              <!--  -->
              <el-input-number
                v-model="bedNum"
                :min="1"
                :max="spareBed"
                :disabled="form.roomType == 1"
                @change="changeBedNum"
              ></el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="支付方式" prop="payType">
              <el-select
                clearable
                v-model="form.payType"
                @change="paymentTypeChange"
                placeholder="请选择支付方式"
              >
                <el-option
                  v-for="(item, index) of payTypeList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                  >{{ item.label }}</el-option
                >
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="支付时间类型" prop="payState">
              <el-select
                clearable
                v-model="form.payState"
                @change="paymentTypeChange"
                placeholder="请选择支付时间类型"
              >
                <el-option
                  v-for="(item, index) of payStateList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                  >{{ item.label }}</el-option
                >
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="支付金额" prop="payMoney">
              <el-input
                v-model="form.payMoney"
                placeholder=""
                style="width: 200px"
                disabled
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="form.payState == 1 && form.payType == 2">
            <el-form-item label="条形码" prop="payCode">
              <el-input
                focus
                v-model="form.payCode"
                placeholder="请输入条形码"
                @change="handleScanCode"
                ref="code"
                style="width: 200px"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submit">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  fetchList,
  fetchRoomList,
  addCompartmentOrder,
  putCompartmentOrder,
  chargeback,
  delCompartmentOrder,
} from "@/api/system/orderList/compartmentOrder";
import {
  fetchRegionList,
  fetchStoreList,
  fetchOrderList,
  listtechnician,
  payment,
} from "@/api/system/orderList/order";
import { listMemberUser } from "@/api/system/card/storeCard";

export default {
  name: "CompartmentOrder",
  data() {
    return {
      // visible: false, //弹出层
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderId: null,
        userName: null,
        phone: null,
      },
      // 显示搜索条件
      showSearch: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 遮罩层
      loading: true,
      // 列表数据
      dataList: [],
      // 总条数
      total: 0,
      // 表单参数
      form: {},
      formList: {},
      // 床位数量
      bedNum: 1,
      // 床位数量
      spareBed: 100, // 最大
      // 表单校验
      rules: {
        areaId: [
          { required: true, message: "请选择所属区域", trigger: "blur" },
        ],
        shopId: [
          { required: true, message: "请选择所属门店", trigger: "blur" },
        ],
        phone: [
          { required: true, message: "请输入客户手机号", trigger: "blur" },
          {
            pattern: /^1[3456789]\d{9}$/,
            message: "请输入正确的手机号码",
            trigger: "blur",
          },
        ],
        userName: [
          { required: true, message: "请输入客户姓名", trigger: "blur" },
        ],
        technicianId: [
          { required: true, message: "请选择技师", trigger: "blur" },
        ],
        startTime: [
          { required: true, message: "请选择开始时间", trigger: "blur" },
        ],
        endTime: [
          { required: true, message: "请选择结束时间", trigger: "blur" },
        ],
        roomId: [{ required: true, message: "请选择包间", trigger: "blur" }],
        roomType: [
          { required: true, message: "请选择包间类型", trigger: "blur" },
        ],
        bedNum: [
          { required: true, message: "请输入床位数量", trigger: "blur" },
        ],
        payType: [
          { required: true, message: "请选择支付方式", trigger: "blur" },
        ],
        payState: [
          { required: true, message: "请选择支付时间类型", trigger: "blur" },
        ],
        payCode: [{ required: true, message: "请输入支付码", trigger: "blur" }],
      },
      rulesList: {
        payCode: [{ required: true, message: "请输入支付码", trigger: "blur" }],
      },
      // 是否显示弹出层
      open: false,
      // 弹出层标题
      title: "新增包间订单",
      // 区域列表
      areaList: [],
      // 门店列表
      storeList: [],
      // 用户列表
      userNamelist: [],
      // 订单列表
      orderList: [],
      // 技师列表
      technicianList: [],
      // 包间列表
      roomList: [],
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < new Date().getTime();
        },
      },
      roomTypeList: [
        {
          value: 1,
          label: "包间",
        },
        {
          value: 2,
          label: "床位",
        },
      ],
      payTypeList: [
        {
          value: 1,
          label: "余额支付",
        },
        {
          value: 2,
          label: "扫码支付",
        },
        {
          value: 3,
          label: "现金支付",
        },
      ],
      payStateList: [
        {
          value: 1,
          label: "立即支付",
        },
        {
          value: 2,
          label: "稍后支付",
        },
      ],
    };
  },
  created() {
    this.getList();
    this.getRegionOption();
    this.getListMemberUser();
  },
  mounted() {},
  methods: {
    // 多选
    handleSelectionChange(e) {
      this.ids = e.map((item) => item.id);
      this.single = e.length !== 1;
      this.multiple = !e.length;
    },
    // 退单
    handleChargeback(row) {
      chargeback({ roomOrderId: row.roomOrderId }).then((res) => {
        if (res.code == 200) {
          this.$modal.msgSuccess("退单成功");
        }
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    handReset(row) {
      if (row.payType == 2) {
        if (!this.formList.payCode) {
          this.$message({
            type: "warning",
            message: "请填写完整表单",
          });
          return;
        }
        payment({
          roomOrderId: row.roomOrderId,
          payCode: this.formList.payCode,
        }).then((res) => {
          this.getList();
          this.formList = {};
        });
      } else {
        payment({ roomOrderId: row.roomOrderId }).then((res) => {
          this.getList();
        });
      }
    },
    // 获取表格数据
    getList() {
      this.loading = true;
      fetchList(this.queryParams).then((res) => {
        res.rows.forEach((item, index) => {
          item.PayIndex = "Code" + index;
          item.visible = false;
        });
        this.dataList = res.rows;
        this.total = res.total;
        this.loading = false;
      });
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      // bedNum-表单验证
      this.form.bedNum = this.bedNum;
    },
    handleUpdata(row) {
      console.log(row, "row");
      console.log(this.form.shopId, " this.form.shopId");

      this.form = row;
      this.form.technicianId = row.technicianId * 1;
      console.log(row.roomId, "roomId");
      console.log(this.form.roomId, "form.roomId");

      this.changeArea(this.form.areaId);
      this.getTechnicianList(this.form.shopId);
      this.getRoomList({
        orderId: this.form.orderId,
        roomType: this.form.roomType || 1,
        belongStoreId: this.form.shopId,
      });

      this.open = true;
    },

    // 包间类型选择器
    changeRoomType1(val) {
      this.bedNum = 1;
      this.form.bedNum = 1;
      if (val) {
        this.spareBedMim = 1;
        this.spareBed = 100;
        this.getRoomList({ orderStatus: 1, roomType: val });
      } else {
        this.roomList = [];
      }
    },

    // 获取所属区域下拉数据
    getRegionOption() {
      fetchRegionList().then((res) => {
        this.areaList = res.data.map((item) => {
          return {
            value: item.id,
            label: item.regionName,
          };
        });
      });
    },
    // 获取所属门店下拉数据
    getStoreList(regionId) {
      fetchStoreList({ regionId }).then((res) => {
        this.storeList = res.data.map((item) => {
          return {
            label: item.storeName,
            value: item.id,
          };
        });
      });
    },
    // 获取用户下拉数据
    getListMemberUser() {
      listMemberUser().then((res) => {
        this.userNamelist = res.rows.map((rItem) => {
          return {
            key: rItem.id,
            value: rItem.phoneNumber,
            userName: rItem.userName,
            gender: rItem.sex,
            birthday: rItem.birthday,
          };
        });
      });
    },
    // 获取包间下拉数据
    getRoomList(params) {
      fetchRoomList(params).then((res) => {
        this.roomList = res.data.zyStoreCompartments.map((item) => {
          return {
            ...item,
            value: item.id,
            label: item.compartmentName,
          };
        });
        if (params.orderId) {
          // 订单
          this.orderObj = res.data.zyOrder;
          this.bedNum = res.data.bedNumber;
          this.form.bedNum = res.data.bedNumber;
          this.form.startTime = this.orderObj.subscribeStartTime;
          this.form.endTime = this.orderObj.subscribeEndTime;
          if (this.form.roomType == 1) {
            this.form.payMoney = this.orderObj.privateRoomPrice;
          }
          if (this.form.roomType == 2) {
            this.form.payMoney = this.orderObj.bedNumber * this.orderObj.price;
          }
        }
      });
    },
    // 获取技师下拉数据
    getTechnicianList(belongStoreId) {
      listtechnician({ belongStoreId, onTheJob: 1 }).then((res) => {
        this.technicianList = res.rows.map((item) => {
          return {
            value: item.id,
            label: item.name,
            // jobNumber: item.jobNumber,
          };
        });
      });
    },
    // 所属区域选择器
    changeArea(val) {
      const selectedOption = this.areaList.find((item) => item.value == val);
      if (selectedOption) {
        this.form.areaName = selectedOption.label;
      } else {
        this.form.shopId = null;
        this.form.shopName = "";
        this.form.technicianId = null;
        this.technicianList = [];
      }
      this.getStoreList(val);
    },
    // 下拉选择器远程搜索订单
    orderRemoteMethod(query) {
      if (query !== "") {
        fetchOrderList({
          pageNum: 1,
          pageSize: 10,
          orderId: query,
        }).then((res) => {
          this.orderList = res.rows.map((item) => {
            return {
              ...item,
              label: item.id,
              value: item.id,
            };
          });
        });
      } else {
        this.options = [];
      }
    },
    // 所属门店选择器
    changeStore(val) {
      const selectedOption = this.storeList.find((item) => item.value == val);
      if (selectedOption) {
        this.form.shopName = selectedOption.label;
      } else {
        this.form.technicianId = null;
      }
      this.getTechnicianList(val);
    },
    // 客户手机号选择器
    changeUserPhone(val) {
      const selectedOption = this.userNamelist.find((item) => item.key === val);
      if (selectedOption) {
        this.form.phone = selectedOption.value;
        this.form.userName = selectedOption.userName;
      } else {
        this.form.phone = null;
        this.form.userName = "";
      }
    },
    // 包间类型选择器
    changeRoomType(val) {
      this.bedNum = 1;
      this.form.bedNum = 1;
      if (val) {
        this.form.roomId = null;
        this.spareBedMim = 1;
        this.spareBed = 100;
        this.getRoomList({ orderStatus: 1, roomType: val });
      } else {
        this.roomList = [];
      }
    },
    // 订单选择器
    changeOrder(val) {
      this.form.roomId = null;
      this.getRoomList({
        orderId: val,
        roomType: this.form.roomType || 1,
        belongStoreId: this.form.shopId,
      });
    },
    // 包间选择器
    changeRoom(val) {
      const selectedOption = this.roomList.find((item) => item.value == val);
      console.log("selectedOption", selectedOption, "this.bedNum", this.bedNum);
      if (selectedOption) {
        this.orderObj = selectedOption;
        this.form.roomName = selectedOption.label;
        if (this.form.roomType == 1) {
          this.form.payMoney = selectedOption.privateRoomPrice;
          this.spareBed = selectedOption.spareBed;
          this.bedNum = selectedOption.spareBed;
          this.form.bedNum = selectedOption.spareBed;
        } else if (this.form.roomType == 2) {
          this.form.payMoney =
            Number(this.bedNum) * Number(selectedOption.price);
          this.spareBed = selectedOption.spareBed;
          if (this.bedNum < this.spareBed) return;
          if (this.bedNum >= this.spareBed) {
            this.bedNum = this.spareBed;
            this.form.bedNum = this.spareBed;
          }
        }
      }
    },
    // 床位数量计数器
    changeBedNum(currentValue, oldValue) {
      if (currentValue >= this.spareBed) {
        this.$message({
          type: "warning",
          message: "床位数量不能大于剩余床位数量",
        });
      }
      this.form.bedNum = this.bedNum;
      if (this.form.roomType == 2) {
        this.form.payMoney = this.form.bedNum * this.orderObj.price;
      }
    },
    /** 批量删除按钮操作 */
    handleDelete(row) {
      const ids = this.ids;
      this.$modal
        .confirm('是否确认删除编号为"' + row.roomOrderId + '"的数据项？')
        .then(function () {
          return delCompartmentOrder(row.roomOrderId);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    // 表单重置
    reset() {
      this.form = {};
      this.bedNum = 1;
      this.spareBed = 100;
      this.resetForm("form");
    },
    // 新增提交
    submit() {
      let { startTime, endTime } = this.form;
      if (new Date(endTime).getTime() <= new Date(startTime).getTime()) {
        this.$message({
          type: "warning",
          message: "结束时间不能小于开始时间",
        });
        return;
      }
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.roomOrderId) {
            putCompartmentOrder(this.form).then((res) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
              this.reset();
            });
          } else {
            addCompartmentOrder(this.form).then((res) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
              this.reset();
            });
          }
        }
      });
    },
    // 取消新增
    cancel() {
      this.open = false;
    },
    //监听扫码枪
    handleScanCode(event) {
      console.log("回车事件--->", event);
      this.$modal.msgSuccess("扫码成功，请点击确认收款");
      this.form.payCode = event;
    },
    //弹窗支付方式变更
    paymentTypeChange(e) {
      console.log("支付方式-->", e);
      if (this.form.payState == 1 && this.form.payType == 2) {
        this.$nextTick(() => {
          this.$refs.code.focus();
        });
      }
    },
    //列表支付下拉 监听扫码枪
    handleScanCode1(event) {
      console.log("回车事件--->", event);
      this.$modal.msgSuccess("扫码成功，请点击确认收款");
      this.formList.payCode = event;
    },
    paymentTypeChange1(e, PayIndex) {
      if (e == 2) {
        this.$nextTick(() => {
          this.$refs[PayIndex].focus();
        });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.el-button {
  margin: 0 5px;
}
</style>
